using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;

namespace Jonathan.AlphaGradientPanel
{
    [TypeConverter(typeof(ColorWithAlphaTypeConverter)), DesignTimeVisible(false), ToolboxItem(false), System.Serializable()]
    public class ColorWithAlpha : Component
    {

        private Control ctlParent;

        [Browsable(false)]
        public Control Parent
        {
            get { return ctlParent; }
            set { ctlParent = value; }
        }

        public ColorWithAlpha ()
            : base()
        {
            Invalidate();
        }

        public void Invalidate ()
        {
            if ((Parent != null))
            {
                Parent.Invalidate();
            }
        }

        private Color clColor = SystemColors.Control;
        private int iAlpha = 255;

        public Color Color
        {
            get { return clColor; }
            set
            {
                clColor = value;
                Invalidate();
            }
        }

        public int Alpha
        {
            get { return iAlpha; }
            set
            {
                iAlpha = value;
                Invalidate();
            }
        }
    }
}